package com.bc.bcapi.service;

import com.bc.bcmodel.consts.GlobalSettings;
import com.bc.commonentity.common.JsonResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.math.BigInteger;

import com.bc.bcapi.dao.T_Activity_topMapper;
import com.bc.bcmodel.domain.T_Activity_topModel;

/**
 * @Name T_Activity_topService * @Description  * @Author generation * @Date 2018/10/31 15:40:08 * @Version 1.0
 **/
@Service
public class T_Activity_topService {
    @Resource
    T_Activity_topMapper t_Activity_topMapper;
    @Resource
    LanguageService languageService;

    /**
     * 保存单条数据     *      * @return
     */
    public int insert(T_Activity_topModel req) {
        return t_Activity_topMapper.insert(req);
    }

    /**
     * 批量增加数据     *      * @return
     */
    public int insertBatch(List<T_Activity_topModel> req) {
        return t_Activity_topMapper.insertBatch(req);
    }

    /**
     * 根据对象属性查找满足条件的第一条数据     *      * @return
     */
    public T_Activity_topModel findByNamedParam(T_Activity_topModel req) {
        return t_Activity_topMapper.findByNamedParam(req);
    }

    /**
     * 根据对象查询所有数据     *      * @return
     */
    public List<T_Activity_topModel> getAllList(T_Activity_topModel req) {
        return t_Activity_topMapper.findByNamedParamList(req);
    }

    /**
     * 根据对象查询所有分页数据     *      * @return
     */
    public PageInfo<T_Activity_topModel> getList(T_Activity_topModel req) {
        PageHelper.startPage(req.getPage_index(), req.getPage_size());
        List<T_Activity_topModel> list = t_Activity_topMapper.findByNamedParamList(req);
        return new PageInfo<T_Activity_topModel>(list);
    }

    /**
     * 更新指定对象     *      * @return
     */
    public int update(T_Activity_topModel req) {
        return t_Activity_topMapper.update(req);
    }

    /**
     * 删除指定数据     *      * @return
     */
    public int delete(BigInteger id) {
        return t_Activity_topMapper.delete(id);
    }

    /**
     * 根据条件统计数据量     *      * @return
     */
    public long count(T_Activity_topModel req) {
        return t_Activity_topMapper.count(req);
    }

    public JsonResult getTop(HttpServletRequest request, HttpServletResponse response) {
//        T_Activity_topModel t_activity_topModel = new T_Activity_topModel();
        List<T_Activity_topModel> data = getAllList(null);
        return new JsonResult(data);
    }
}